<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>bfpy.bfservice.ServiceDef</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="bfpy-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/bfpy/">BfPy</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="bfpy-module.html">Package&nbsp;bfpy</a> ::
        <a href="bfpy.bfservice-module.html">Module&nbsp;bfservice</a> ::
        Class&nbsp;ServiceDef
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="bfpy.bfservice.ServiceDef-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class ServiceDef</h1><p class="nomargin-top"><span class="codelink"><a href="bfpy.bfservice-pysrc.html#ServiceDef">source&nbsp;code</a></span></p>
<pre class="base-tree">
       object --+    
                |    
<a href="bfpy.bfservice.ServiceDescriptor-class.html">ServiceDescriptor</a> --+
                    |
                   <strong class="uidshort">ServiceDef</strong>
</pre>

<dl><dt>Known Subclasses:</dt>
<dd>
      <ul class="subclass-list">
<li><a href="bfpy.bfservice.ExchangeServiceDef-class.html">ExchangeServiceDef</a></li><li>, <a href="bfpy.bfservice.GlobalServiceDef-class.html">GlobalServiceDef</a></li><li>, <a href="bfpy.bfservice.VendorServiceDef-class.html">VendorServiceDef</a></li>  </ul>
</dd></dl>

<hr />
<p>Definition and implementation of a service. The definition includes 
  the name of the method, the service name, endPoint to go to, name of the 
  request argument (and if an API header has to be added to it) and error 
  codes that should be skipped, together with a list of post processing 
  callables.</p>
  <p>The service name can be derived from the methodName and so can the 
  requestName from the methodName. This is due to the regularity of many 
  services in the Betfair API.</p>
  <p>Some of the Betfair API errorCodes are indications and that is why 
  they can be skipped. This also serves to delay checking for wrongly 
  served errorCodes (INVALID_MARKET instead of MARKET_CLOSED in 
  getMarketProfitAndLoss)</p>
  <p>The extra (kwargs) held by the parent class, allows the provision of 
  default values for arguments to a method, so the user will not need to 
  provide them. This feature also covers the problem that some parameters 
  are signaled as optional in the Betfair documentation when they are not. 
  If the user does not provide them the default value will be applied.</p>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bfpy.bfservice.ServiceDef-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">endPoint</span>,
        <span class="summary-sig-arg">methodName</span>,
        <span class="summary-sig-arg">serviceName</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">requestName</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">apiHeader</span>=<span class="summary-sig-default">True</span>,
        <span class="summary-sig-arg">skipErrorCodes</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">preProc</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">postProc</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">weight</span>=<span class="summary-sig-default">0</span>,
        <span class="summary-sig-arg">**kwargs</span>)</span><br />
      Initializes the service and variables</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bfpy.bfservice-pysrc.html#ServiceDef.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bfpy.bfservice.ServiceDef-class.html#__call__" class="summary-sig-name">__call__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">instance</span>,
        <span class="summary-sig-arg">*args</span>,
        <span class="summary-sig-arg">**kwargs</span>)</span><br />
      Invocation of a service in a generic manner.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bfpy.bfservice-pysrc.html#ServiceDef.__call__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code><a href="bfpy.bfservice.ServiceDescriptor-class.html">ServiceDescriptor</a></code></b>:
      <code><a href="bfpy.bfservice.ServiceDescriptor-class.html#__get__">__get__</a></code>
      </p>
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__delattr__</code>,
      <code>__format__</code>,
      <code>__getattribute__</code>,
      <code>__hash__</code>,
      <code>__new__</code>,
      <code>__reduce__</code>,
      <code>__reduce_ex__</code>,
      <code>__repr__</code>,
      <code>__setattr__</code>,
      <code>__sizeof__</code>,
      <code>__str__</code>,
      <code>__subclasshook__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== INSTANCE VARIABLES ==================== -->
<a name="section-InstanceVariables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceVariables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">bool</span>
    </td><td class="summary">
        <a name="apiHeader"></a><span class="summary-name">apiHeader</span><br />
      whether to add an API header to the request
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">int</span>
    </td><td class="summary">
        <a name="endPoint"></a><span class="summary-name">endPoint</span><br />
      location endPoint of the service (0 Global, 1 Exchange)
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">str</span>
    </td><td class="summary">
        <a name="methodName"></a><span class="summary-name">methodName</span><br />
      name the descriptor will be invoked by
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">list</span>
    </td><td class="summary">
        <a name="postProc"></a><span class="summary-name">postProc</span><br />
      callables that will post process a service response
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">list</span>
    </td><td class="summary">
        <a name="preProc"></a><span class="summary-name">preProc</span><br />
      callables that will pre process a service request
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">str</span>
    </td><td class="summary">
        <a name="requestName"></a><span class="summary-name">requestName</span><br />
      name of the request to pass to the service
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">str</span>
    </td><td class="summary">
        <a name="serviceName"></a><span class="summary-name">serviceName</span><br />
      name of the service to invoke
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">list</span>
    </td><td class="summary">
        <a name="skipErrorCodes"></a><span class="summary-name">skipErrorCodes</span><br />
      errorCodes that will not signal an error
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code><a href="bfpy.bfservice.ServiceDescriptor-class.html">ServiceDescriptor</a></code></b>:
      <code><a href="bfpy.bfservice.ServiceDescriptor-class.html#kwargs">kwargs</a></code>
      </p>
    <div class="private">    <p class="indent-wrapped-lines"><b>Inherited from <code><a href="bfpy.bfservice.ServiceDescriptor-class.html">ServiceDescriptor</a></code></b> (private):
      <code><a href="bfpy.bfservice.ServiceDescriptor-class.html#_instanceCache" onclick="show_private();">_instanceCache</a></code>
      </p></div>
    </td>
  </tr>
</table>
<!-- ==================== PROPERTIES ==================== -->
<a name="section-Properties"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Properties</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Properties"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__class__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">endPoint</span>,
        <span class="sig-arg">methodName</span>,
        <span class="sig-arg">serviceName</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">requestName</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">apiHeader</span>=<span class="sig-default">True</span>,
        <span class="sig-arg">skipErrorCodes</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">preProc</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">postProc</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">weight</span>=<span class="sig-default">0</span>,
        <span class="sig-arg">**kwargs</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bfpy.bfservice-pysrc.html#ServiceDef.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Initializes the service and variables</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>endPoint</code></strong> (int) - location endPoint of the service (0 Global, 1 Exchange)</li>
        <li><strong class="pname"><code>methodName</code></strong> (str) - name the method will be invoked by</li>
        <li><strong class="pname"><code>serviceName</code></strong> (str) - name of the service to invoke</li>
        <li><strong class="pname"><code>requestName</code></strong> (str) - name of the request to pass to the service</li>
        <li><strong class="pname"><code>apiHeader</code></strong> (bool) - whether to add an API header to the request</li>
        <li><strong class="pname"><code>skipErrorCodes</code></strong> (list) - errorCodes that will not signal an error</li>
        <li><strong class="pname"><code>preProc</code></strong> (list) - callables that will pre process a service request</li>
        <li><strong class="pname"><code>postProc</code></strong> (list) - callables that will post process a service response</li>
        <li><strong class="pname"><code>weight</code></strong> (int) - weight count into data charges. Negative values are assumed to be
          multiplied by 5 (and passed as positive)</li>
        <li><strong class="pname"><code>kwargs</code></strong> (dict) - extra arguments (with values) to pass to the method</li>
    </ul></dd>
    <dt>Overrides:
        object.__init__
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="__call__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__call__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">instance</span>,
        <span class="sig-arg">*args</span>,
        <span class="sig-arg">**kwargs</span>)</span>
    <br /><em class="fname">(Call operator)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bfpy.bfservice-pysrc.html#ServiceDef.__call__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Invocation of a service in a generic manner.</p>
  <p>It is in charge of deciding the final endPoint (global or exchange, 
  and if exchange, which one from the parameters), get a reference to the 
  service method from the instance, the request to be passed and filling in
  the request values (with the default and provided kwargs)</p>
  <p>Once the response is received, it is passed through the defined post 
  processing callables and then returned</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>instance</code></strong> (object) - object whose method is being invoked</li>
        <li><strong class="pname"><code>args</code></strong> (tuple) - exchange services will receive the exchangeId there</li>
        <li><strong class="pname"><code>kwargs</code></strong> (dict) - names and values of args for the service request</li>
    </ul></dd>
    <dt>Raises:</dt>
    <dd><ul class="nomargin-top">
        <li><code><strong class='fraise'>NotImplemented</strong></code> - pure virtual function</li>
    </ul></dd>
    <dt>Overrides:
        <a href="bfpy.bfservice.ServiceDescriptor-class.html#__call__">ServiceDescriptor.__call__</a>
    </dt>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="bfpy-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/bfpy/">BfPy</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sat Jun 04 02:13:34 2011
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
